﻿/***************
 * Copyright 2009 (C) 
 * Timur Fanshteyn
 * Blog: http://blog.tfanshteyn.com
 * ************/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Coherence.Linq;
using System.Linq.Expressions;
using Tangosol.Util.Extractor;

namespace Coherence.Contrib
{
    public class MetadataCoherenceQueryTranslator : CoherenceQueryTranslator
    {
        protected override Expression VisitMemberAccess(MemberExpression m)
        {
            if (m.Expression != null && m.Expression.NodeType == ExpressionType.Parameter)
            {
                globalFilter = new ReflectionExtractor("getProperty", new object[] {m.Member.Name});
                return m;
            }
            throw new NotSupportedException(string.Format("The member '{0}' is not supported", m.Member.Name));
        }

    }
}
